﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using KNS.Invoice.UI;
using System.IO;


namespace InvoiceManagement
{
    public partial class frmMain : KNSFormBase
    {

        #region "Khai báo biến"
        public frmMain()
        {
            InitializeComponent();
        }
        #endregion

        #region "Các hàm load dữ liệu"

        #endregion

        #region "Các hàm sự kiện trên form"
      

      
        
        #endregion

        #region "Các hàm xử lý khác"
        public void SetColor(bool isClick, KNSButton btn)
        {
            if (isClick == true)
            {
                btn.LookAndFeel.SkinName = "Money Twins";
                btn.LookAndFeel.UseDefaultLookAndFeel = false;
            }
            else
            {
                btn.LookAndFeel.SkinName = "Black";
            }
        }
        #endregion                             

        private void btnHeThong_Click(object sender, EventArgs e)
        {
            SetColor(true, btnHeThong);
            panel4.Controls.Clear();
            panel4.Controls.Add(grpHeThong);
            grpHeThong.Visible = true;
            grpDanhMuc.Visible = false;
            grpHoaDon.Visible = false;
            grpBaoCao.Visible = false;
            grpHeThong.Location = new Point(5, 0);
        }

        private void btnHeThong_Leave(object sender, EventArgs e)
        {
            SetColor(false, btnHeThong);
            
        }

        private void btnDanhMuc_Click(object sender, EventArgs e)
        {
            SetColor(true, btnDanhMuc);
            panel4.Controls.Clear();
            panel4.Controls.Add(grpDanhMuc);
            grpHeThong.Visible = false;
            grpDanhMuc.Visible = true;
            grpHoaDon.Visible = false;
            grpBaoCao.Visible = false;
            grpHeThong.Location = new Point(5, 0);
        }

        private void btnDanhMuc_Leave(object sender, EventArgs e)
        {
            SetColor(false, btnDanhMuc);
        }

        private void btnHoaDon_Click(object sender, EventArgs e)
        {
            SetColor(true, btnHoaDon);
            panel4.Controls.Clear();
            grpHoaDon.Visible = true;
            panel4.Controls.Add(grpHoaDon);
            grpHeThong.Visible = true;
            grpDanhMuc.Visible = false;
            
            grpBaoCao.Visible = false;
            grpHeThong.Location = new Point(5, 0);
        }

        private void btnHoaDon_Leave(object sender, EventArgs e)
        {
            SetColor(false, btnHoaDon);
        }

        private void btnBaoCao_Click(object sender, EventArgs e)
        {
            SetColor(true, btnBaoCao);            
            panel4.Controls.Add(grpBaoCao);
            
            grpHoaDon.BringToFront();
            grpHeThong.Visible = false;
            grpDanhMuc.Visible = false;
            grpHoaDon.Visible = false;
            grpBaoCao.Visible = true;
            grpHeThong.Location = new Point(5, 0);
        }

        private void btnBaoCao_Leave(object sender, EventArgs e)
        {
            SetColor(false, btnBaoCao);
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            SetGroup();
            btnHeThong_Click(sender, e);
        }

        public void SetGroup()
        {
            grpHeThong.Visible = false;
            grpDanhMuc.Visible = false;
            grpHoaDon.Visible = false;
            grpBaoCao.Visible = false;          
        }

        private void btnDoiMatKhau_Click(object sender, EventArgs e)
        {
            frmChangePassword frm = new frmChangePassword();
            SetFormActive(frm,panel2);
            frm.WindowState = FormWindowState.Normal;
        }

        private void btnNhomNguoiDung_Click(object sender, EventArgs e)
        {
            frmNhomNguoiDung frm = new frmNhomNguoiDung();
            SetFormActive(frm, panel2);                        
        }

        private void btnNguoiDung_Click(object sender, EventArgs e)
        {
            frmNguoiDung frm = new frmNguoiDung();
            SetFormActive(frm, panel2);    
        }

        private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (KNSMessageBox.Show("Bạn có chắc muốn thoát chương trình?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Application.Exit();
            }
            else
            {
                frmMain frm = new frmMain();
                frm.Show();
            }
        }

        private void btnSaoLuu_Click(object sender, EventArgs e)
        {
            frmSaoLuu frm = new frmSaoLuu();
            SetFormActive(frm, panel2); 
        }

        private void btnPhucHoi_Click(object sender, EventArgs e)
        {
            frmPhucHoi frm = new frmPhucHoi();
            SetFormActive(frm, panel2); 
        }

        private void btnDMKhachHang_Click(object sender, EventArgs e)
        {
            frmDMKhachHang frm = new frmDMKhachHang();
            SetFormActive(frm, panel2); 
        }

        private void btnDMHangHoa_Click(object sender, EventArgs e)
        {
            frmDMHangHoa frm = new frmDMHangHoa();
            SetFormActive(frm, panel2); 
        }

        private void btnDMCoQuanThue_Click(object sender, EventArgs e)
        {

        }

        private void btnTKSoBanSao_Click(object sender, EventArgs e)
        {

        }

        private void btnLoaiThue_Click(object sender, EventArgs e)
        {
            // frm = new frmDMHangHoa();
            //SetFormActive(frm, panel2); 
        }

        private void btnDMDonViTinh_Click(object sender, EventArgs e)
        {
            frmDMDonViTinh frm = new frmDMDonViTinh();
            SetFormActive(frm, panel2); 
        }
                                                                 
    }
}